package org.example.utils;


import java.util.Map;

public class ThreadLocalUtil {
    // 提供 threadLocal 对象
    private static final ThreadLocal THREAD_LOCAL = new ThreadLocal();

    // 根据拣货区值
    public static <T> T get() {
        return (T) THREAD_LOCAL.get();
    }

    // 设置
    public static void set(Object value) {
        THREAD_LOCAL.set(value);
    }

    // 清除
    public static void remove() {
        THREAD_LOCAL.remove();
    }

    // 用于返回存在token中的用户信息
    public static <T> T getClaimsByKey(String key) {
        Map<String, Object> claims = ThreadLocalUtil.get();
        return (T) claims.get(key);
    }
}
